package javabase.schoolwork.day5_31;

/**
 * @author fance
 * @date 2018/5/31 21:43
 */
public class Bank {
    private String num;
    private String password;
    private Bank(){}
    private static Bank bank = new Bank();
    public static Bank getBanking() {
        return bank;
    }
    public String getNum() {
        return num;
    }

    public void setNum(String num) throws Exception {
        if (num.length() >= 12 && num.length() <= 21 && judge(num)) {
            this.num = num;
        } else {
            throw new Exception("e...");
        }
    }

    public String getPassword() {

        return password;
    }

    public void setPassword(String password) throws Exception {
        if (password.length() == 6 && judge(password)) {
            this.password = password;
        } else {
            throw new Exception("e...");
        }
    }
    private boolean judge(String s) {
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) > '9' || s.charAt(i) < '0') {
                return false;
            }
        }
        return true;
    }
}
